CSCI 131,

Fall 2003,

Test 2.


  1. [5 pts] Define Abstract Data Type.

  2. [5 pts] The complexity of an algorithm is a measure of the effort expended in performing a computation, (often expressed as O(f(n)), as in O(n), or O(n2). Give pseudo code for an O(n) algorithm to find an item in an array. Why is this algorithm O(n).

  3. [5 pts] What is a class constructor? When and how is a constructor invoked? Why is a facility for a constructor provided?

  4. [5 pts] What does it mean to overload a function? Give an example.

  5. [5 pts] Describe the role of the preprocessor, compiler and linker in producing executable code from source code. Discuss how placing the source code in multiple files is handled using these tools.

  6. [5 pts] Show how to, and explain all parts of declaring an array. Describe what each portion of the declaration does.

  7. [5 pts] Compare and contrast arrays and structs. (Ie how are they the same and how are they different)

  8. [5 pts] Discuss out of bounds array indexing errors. (What this is, what this can cause to happen)

  9. [5 pts] Write a routine, which takes an array of integers, and an integer representing the number of data items in that array as parameters, returns the average value of the numbers stored in the array.

  10. [ 5 pts] Write a routine which given an array of integers between 1 and 50, and an integer representing the number of data items in that array as parameters, finds the item that occurs most frequently. Hint: use a second array.